<!--
 * @Author: your name
 * @Date: 2022-03-09 14:24:07
 * @LastEditTime: 2022-03-09 14:41:33
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE.
 * @FilePath: \day09\5-事件捕获.html
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
       #outer{
            width: 400px;
            height: 400px;
            background-color: aqua;
        }
        #contenter{
            width: 200px;
            height: 200px;
            background-color: red;
            margin: 0 auto;
        }
        #inner{
            width: 100px;
            height: 100px;
            background-color: blue;
            margin: 0 auto;
        }
    </style>
    <script>
       window.onload=function(){
         
          var outer=document.getElementById('outer');
           var contenter=document.getElementById('contenter');
           var inner=document.getElementById('inner');
         
           function handler(){
               console.log(this.id);
           }
           inner.addEventListener('click',handler,true);
           contenter.addEventListener('click',handler,true);
           outer.addEventListener('click',handler,true)

       } ; 
    </script>
</head>
<body>
    <div id="outer">外部
        <div id="contenter">中间
            <div id="inner">内部</div>
        </div>
    </div>
    <script>
         
    </script>
</body>
</html>